import axios from 'axios'

const service = axios.create({
	baseURL: 'http://10.200.20.54:8080',
	timeout: 180000
})
// request拦截器
service.interceptors.request.use(config => {
	config.headers['Authorization'] = 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjA2Y2EzY2VkLTY3YTItNGFlZS1hZjNkLTU0NDY5MDRmYmNkMiJ9.G0kmgakJshFAJ5ghmLTiIg3O0rtfMaWaaAp86MEPKO8t3CTSgYX5xMRQio03F5o8F_sZbwxoLYD8R-_5pg5sYg'
	return config
}, error => {
	Promise.reject(error)
})

const fetch = {
	get: (url, params) => {
		return service({
			method: 'get',
			url: url,
			params: params
		})
	},
	post: (url, params) => {
		return service({
			method: 'post',
			url: url,
			data: params
		})
	},
	download: (url, params) => {
		return service({
			method: 'post',
			url: url,
			data: params,
			responseType: 'blob'
		})
	}
}
export default fetch
